package _0_语法._3_分支;

import java.util.Scanner;

public class _6_计算器 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        double num1;
        double num2;
        String operate;     // 运算符
        double result = 0;  // 运算结果

        System.out.println("请输入第一个数：");
        num1 = scanner.nextDouble();
        System.out.println("请输入第二个数：");
        num2 = scanner.nextDouble();
        System.out.println("请输入符号：");
        operate = scanner.next();

        switch (operate) {
            case "+" : result = num1 + num2; break;
            case "-" : result = num1 - num2; break;
            case "*" : result = num1 * num2; break;
            case "/" : result = num1 / num2; break;
            case "%" : result = num1 % num2; break;
        }

        System.out.println("计算结果为：" + result);
    }
}
